package com.example.tbplus14.utils.html;



import org.springframework.core.io.ClassPathResource;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.UUID;

public class HtmlToImgflying {

    public static void main(String[] args) throws Exception{
        String html = html();

    }


    private static File html2File(String html, String tmpDir) throws IOException {
        String savePath = tmpDir + (tmpDir.endsWith(File.separator) ? "" : File.separator) + UUID.randomUUID() + ".html";
        FileWriter fileWriter = new FileWriter(savePath);
        BufferedWriter writer = new BufferedWriter(fileWriter);
        writer.write(html);
        writer.close();
        fileWriter.close();
        return new File(savePath);
    }

    private static String html()throws Exception{
        ClassPathResource classPathResourceBg = new ClassPathResource("bodybg.png");
        String imageBgPath = classPathResourceBg.getURL().getPath();
        String HtmlTemplateStr = "<div class=\"all\" id=\"all\" style=\"display: flex;justify-content: center;\">\n" +
                "  <div style=\"width: 375px; background: url("+imageBgPath+") no-repeat; font-family: PingFangSC-Regular, PingFang SC; font-size: 12px;\" id=\"card\">\n" +
                "    <div class=\"anda\" style=\"margin-top: 14px; text-align: center;height: 20px;font-size: 14px;font-family: PingFangSC-Medium, PingFang SC;font-weight: 500;color: #FFFFFF;line-height: 20px;\">\n" +
                "      <span>Your Virtual Collection Account</span>\n" +
                "    </div>\n" +
                "    <div style=\"background-color: #ffffff;width: 93%;margin: 14px auto 0;border-radius:8px;padding-top: 14px;padding-bottom: 12px;\">\n" +
                "      <div class=\"card\" style=\"width: 91%;height: 182px;margin: 0 auto;background-size:100%;border-radius:4px\">\n" +
                "        <img id=\"pic\" src=\"\" alt=\"\" style=\"height: 182px\" />\n" +
                "      </div>\n" +
                "      <div class=\"tip\" style=\"width: 310px;height: 34px;font-size: 12px;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;color: #9b9898;line-height: 17px;margin: 14px auto 0;\">\n" +
                "        Your Virtual Collection Account has been opened and you can receive Instapay and Pesonet remittances through your Virtual Collection Account.\n" +
                "      </div>\n" +
                "      <div class=\"divisi\" style=\"width: 303px;height: 1px;background: #D8D8D8;margin: 21px auto 0;\"></div>\n" +
                "      <div class=\"Nomor\" style=\"display: flex;margin-left: 23px;margin-top: 8px;\">\n" +
                "        <span style=\"width: 144px;display: flex;justify-content: space-between;\">Account number<span>:</span></span>\n" +
                "        <span id=\"NomorNum\">&nbsp;&nbsp;</span>\n" +
                "      </div>\n" +
                "      <div class=\"Name\" style=\"display:flex;height:auto;flex-direction:row;margin-left: 23px;margin-top: 3px;padding-right: 1px;align-items: flex-start;\">\n" +
                "        <span style=\"width: 144px;display: flex;justify-content: space-between;\">Name<span>:</span></span>\n" +
                "        <span id=\"NameDetail\">&nbsp;&nbsp;</span>\n" +
                "      </div>\n" +
                "      <div class=\"Name\" style=\"display:flex;height:auto;flex-direction:row;margin-left: 23px;margin-top: 3px;padding-right: 1px;align-items: flex-start;\">\n" +
                "        <span style=\"width: 144px;display: flex;justify-content: space-between;\">Identification Number <span>:</span></span>\n" +
                "        <span id=\"KartNum\">&nbsp;&nbsp;</span>\n" +
                "      </div>\n" +
                "      <div class=\"Name\" style=\"display:flex;height:auto;flex-direction:row;margin-left: 23px;margin-top: 3px;padding-right: 1px;align-items: flex-start;\">\n" +
                "        <span style=\"width: 144px;display: flex;justify-content: space-between;\">Registered bank <span>:</span></span>\n" +
                "        <span class=\"NameDetail\" style=\"width: 166px;word-break: break-all;float: right;margin-top: 4px;font-size: 12px;\" id=\"CabangNum\">&nbsp;&nbsp;</span>\n" +
                "      </div>\n" +
                "      <div class=\"Notice\" style=\"margin-top: 12px;font-size: 12px;color: #9b9898;  width: 97%;padding-left: 2%;\">\n" +
                "        Please check your Virtual Collection Account information. If you have any questions, please seek our help in time\n" +
                "      </div>\n" +
                "    </div>\n" +
                "    <span class=\"power\" style=\"width:100%;text-align: center;display:block;font-size: 12px;font-family: PingFangSC-Regular, PingFang SC;font-weight: 300;color: #e6c6c6;line-height: 20px;margin-top: 10px;margin-bottom: 10px;\">Power by Netbank</span>\n" +
                "  </div>\n" +
                "</div>";
        return HtmlTemplateStr;
    }


}
